function [err] = pref_mom(xpdata,n_prefparms,alpha,w) % log-likelihood for preference estimation

    sigma=alpha(1);
    
    % preference coeficients
    i=1+n_prefparms;
    beta=[1 alpha(2:i)];
    
    sh_inattentive=alpha(end);
    bX1=sum(beta.*xpdata.X1,2);
    bX2=sum(beta.*xpdata.X2,2);
    
    pr=normcdf((bX1-bX2)./(sigma.*2^0.5));
    pr=(1-sh_inattentive).*pr+sh_inattentive/2;

    pr=max(pr,0.0001);
    pr=min(pr,0.9999);

    l=w.*((xpdata.EP_choice==1).*log(pr)+(xpdata.EP_choice==0).*log((1-pr)));
    err=-sum(l,1);
end